﻿@inherits UmbracoTemplatePage

@{ 
    bool showAll = false;
    if (ViewData["show"] != null && (bool)ViewData["show"])
    {
        showAll = true;
    }
}

@{ 
    IPublishedContent root = Model.Content;
    if (!root.DocumentTypeAlias.Equals("consultingIndex"))
    {
        root = Model.Content.AncestorsOrSelf("consultingIndex").FirstOrDefault();
    }
    var childrens = root.Children(x => x.IsVisible());

    if (showAll)
    {
        childrens = childrens.Where(x=> !x.GetPropertyValue<bool>("umbracoNaviHide"));
    }
}
<select class="form-control" id="selConsultType">
    @if (showAll)
    {
        <option value="" data-link="@root.Url">全部</option>
    }

    @foreach (var item in childrens)
    {
        <option value="@item.Id" data-link="@item.Url" @(item.IsEqual(Model.Content)? "selected='selected'" : "")>@item.Name</option>
    }
</select>